//
//  LBXOldTimeFilter.mm
//  OpenGLGame
//
//  Created by Nguyen Cong Huy on 4/23/13.
//  Copyright (c) 2013 UIT. All rights reserved.
//

#include "LBXOldTimeFilter.h"
#include "LBOverlayTextureFilter.h"
#include "LBSharpenFilter.h"
#include "LBGreyscaleFilter.h"
#include "LBSepiaFilter.h"
#include "LBToneCurveFilter.h"
#include "LBUtils.h"

LBXOldTimeFilter::LBXOldTimeFilter(){
    toneCurves = new LBToneCurveFilter();
    
    overlay = new LBOverlayTextureFilter();
    
    sharpen = new LBSharpenFilter();
    sharpen->setSharpness(0.1f);
    
    greyscale = new LBGreyscaleFilter();
    
    sepia = new LBSepiaFilter();
    sepia->setIntensity(0.5f);
    
    toneCurves->addTarget(overlay)->addTarget(sharpen)->addTarget(greyscale)->addTarget(sepia);
    firstFilter = toneCurves;
}

LBXOldTimeFilter::~LBXOldTimeFilter(){
    outputTexture = 0;
    DELETE_SAFELY(toneCurves);
    DELETE_SAFELY(overlay);
    DELETE_SAFELY(sharpen);
    DELETE_SAFELY(greyscale);
    DELETE_SAFELY(sepia);
}

void LBXOldTimeFilter::setBlendTexture(LBTexture* blendTexture){
    overlay->setBlendTexture(blendTexture);
}

void LBXOldTimeFilter::setToneAcvData(unsigned char* toneData){
    toneCurves->setCurveImageData(toneData);
}